type user = {
    id:number,
    name:string
}
function getKey(value:user,key:string){
    //key的结果必须 id\name
    // <类型> (as)
    // keyof 数据类型 ---> [id,name]
    return value[key as keyof user]
}

const res = getKey({id:1,name:"xiaowang"},"name")
console.log(res);
